package com.hsy.linemoney.modules.lanuch;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.View;

import com.deparse.dpframe.ui.android.app.activity.DPBaseActivityWithSimpleActionBar;
import com.deparse.dpframe.ui.android.widget.DPViewPager;
import com.hsy.linemoney.R;
import com.hsy.linemoney.modules.common.CommonBaseFragment;


/**
 * Created by hsy on 2016/4/21.
 */
public class LauncherActivity extends DPBaseActivityWithSimpleActionBar {
    private DPViewPager mViewpagerDPViewPager;

    private static final CommonBaseFragment[] fragments = {
            new FragmentLauncher1(),
            new FragmentLauncher2(),
            new FragmentLauncher3(),
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.launcher_layout);
        getActionBarContainer().setVisibility(View.GONE);
        mViewpagerDPViewPager = (DPViewPager) findViewById(R.id.viewpager);

        for (CommonBaseFragment fragment : fragments) {
            fragment.setAttchedActivity(LauncherActivity.this);
        }

        mViewpagerDPViewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
    }

    class MyPagerAdapter extends FragmentPagerAdapter {

        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public int getCount() {
            return fragments.length;
        }


        @Override
        public Fragment getItem(int position) {
            return fragments[position];
        }
    }
}
